package com.zego.wawaji.third.pay.util;

import android.view.View;

import com.zego.wawaji.base.log.PToast;

import java.util.Calendar;

/**
 * 支付按钮点击间隔
 * Created by Su on 2017/12/18.
 */
public abstract class PayClickListener implements View.OnClickListener {

    // 连续两次点击之间的时间间隔
    public static final int MIN_PAY_CLICK_TIME = 5 * 1000;

    // 上一次的点击时间
    private long lastClickTime = 0;

    @Override
    public void onClick(View v) {
        long currentTime = Calendar.getInstance().getTimeInMillis();
        if (currentTime - lastClickTime > MIN_PAY_CLICK_TIME) {
            lastClickTime = currentTime;
            onPayClick(v);
        } else {
            PToast.showShort("请勿重复提交订单");
        }
    }

    public abstract void onPayClick(View v);
}
